package root.loan;

import exceptions.HasAlreadyDoneException;
import exceptions.LoanHasAlreadyBeenApprovedException;
import exceptions.PermissionDeniedException;

/**
 * Um status de item que foi emprestado mas que ja foi devolvido e confirmado pelo dono.
 */
public class Completed extends State {

	private final String descricao = "Completado";
	
	@Override
	public String getDescricao() {
		return descricao;
	}

	@Override
	public boolean isComplete(){
		return true;
	}
	
	@Override
	public void complete(Borrow borrow) throws HasAlreadyDoneException {
		throw new HasAlreadyDoneException("Término do empréstimo já confirmado");
	}
	
	@Override
	public void cancel(Borrow borrow) throws HasAlreadyDoneException {
		throw new HasAlreadyDoneException("Item já devolvido");
	}
	
	@Override
	public void returnItem(Borrow borrow) throws HasAlreadyDoneException{
		throw new HasAlreadyDoneException("Item já devolvido");
	}
	
	@Override
	public void aproveBorrow(Borrow borrow) throws LoanHasAlreadyBeenApprovedException ,PermissionDeniedException{
		throw new LoanHasAlreadyBeenApprovedException("Empréstimo já aprovado");
	}
	@Override
	public void requestDevolution(Borrow borrow) throws HasAlreadyDoneException ,PermissionDeniedException{
		mudaEstado(borrow,new AcceptedRequested());
	}
}
